<?php
namespace app\admin\controller;
use app\admin\controller\Base;

class Integral extends Base
{
    
    public function index()
    {

       $list=db('user')->field('u.*,i.*')->alias('u')->join('f_information i','u.id=i.userid')->order('u.id')->paginate(5);
        $this->assign('list',$list);
        return view();
    }

     public function setgral()
    {
        $id=input('id');
        $list=db('gral_info')->where('uid',$id)->select();
        foreach ($list as &$val) {
            $val['price'] = db('goods')->where('id',$val['gid'])->find()['price'];
        }
        // var_dump($list);
        // die;
        $count = db('gral_info')->count();
        /*var_dump($count);
        die;*/
       if(empty($list)){
            $this->error('该用户暂无消费记录！');
       }
        $this->assign('count',$count);
        $this->assign('list',$list);
        return view();
    }

      public function getgral()
    {
        $id=input('id');
        $list=db('getgral')->where('uid',$id)->select();
        
        // var_dump($list);
        // die;
        $count = db('getgral')->count();
        /*var_dump($count);
        die;*/
        if(empty($list)){
            $this->error('该用户暂无记录！');
        }
        $this->assign('count',$count);
        $this->assign('list',$list);
        return view();
    }
}